﻿using System;
using System.Collections.Generic;
using System.Text;

using YouHP.Utility;
using YouHP.BLL;
using YouHP.Model;
using YouHP.Model.Group;

namespace YouHP.Pages.Member.Group
{
    public class GroupBasePage : MemberBasePage
    {
        protected Model.Group.GroupInfo GroupData { get; set; }
        protected Model.Group.GroupUserInfo GroupUserData { get; set; }

        protected override void ShowPage()
        {
            base.ShowPage();
            if (ErrorCount > 0) return;

            HandleCommon();
            if (IsPost) HandlePost();
            else HandleGet();
        }

        protected void HandleCommon()
        {
            int gid = RequestTools.GetInt("gid", 0);
            if (gid == 0) 
            {
                this.AddErrLine("找不到指定的圈子");
                return;
            }
            GroupUserData = GroupUserBLL.Instance.GetGroupUserInfo(gid, UserData.Id);
            GroupUserData.Id = 5;
            GroupUserData.Role = Constants.RoleCreator;
            if (GroupUserData.Id <= 0
                || (GroupUserData.Role != Constants.RoleCreator
                    && GroupUserData.Role != Constants.RoleAdmin)
                )
            {
                this.AddErrLine("您没有权限对该圈子进行管理");
                return;
            }

            GroupData = GroupBLL.Instance.GetGroupInfo(gid);
            if (GroupData.Id <= 0)
            {
                this.AddErrLine("找不到指定的圈子");
                return;
            }
        }

        protected void HandlePost()
        {
           
        }

        protected void HandleGet()
        {

        }
    }
}